<template>
	<div>
		<div class="searchForm">
		    <div style="display: flex;">
		        <div>
					用户手机号/用户姓名：
				</div>
				<div>
					<selectUser ref="selectUser" @getUserId="getUserId"  />
				</div>
				<div style="margin-left: 10px;">
					状态：
				</div>
				<div >
					<el-radio-group v-model="renzheng_status">
					      <el-radio label="-1">全部</el-radio>
					      <el-radio label="0">未认证</el-radio>
						  <el-radio label="1">已认证</el-radio>
					</el-radio-group>
				</div>
				<div style="margin-left: 10px;">
				    <el-button type="primary" size="mini" @click="search">检索</el-button>
				    <el-button size="mini" @click="clearSearch">重置/检索</el-button>
				</div>
		    </div>
		</div>
		<br/>
		<el-table  :data="list"
			 border  
			 style="width: 100%"
			>
			<el-table-column   align="center"    prop="phone"  label="注册手机号"></el-table-column>
		    <el-table-column   align="center"    prop="add_time"  label="添加时间"></el-table-column>
			<el-table-column   align="center"    prop="update_time"  label="修改时间"></el-table-column>
			 <el-table-column  label="实名认证状态"   align="center">
			      <template slot-scope="scope">
			         <div>
						{{scope.row.renzheng_status==0?'未认证':'已认证'}}
			 		</div>
			      </template>
			  </el-table-column>
			<el-table-column   align="center"    prop="renzheng_time"  label="认证时间"></el-table-column>
			<el-table-column   align="center"    prop="name"  label="真实姓名"></el-table-column>
			<el-table-column   align="center"    prop="mobile"  label="认证手机号"></el-table-column>
			<el-table-column   align="center"    prop="idcard"  label="身份证号"></el-table-column>
			<el-table-column   align="center"    prop="wx_number"  label="微信号"></el-table-column>
			
		   <el-table-column  label="操作"   align="center">
		        <template slot-scope="scope">
					<!-- <el-button type="text" @click="editRow(scope.row)">编辑</el-button> -->
					<div class="button_text" @click="editRow(scope.row)" style="margin-right: 10px;">
						编辑
					</div>
					<div class="button_text" @click="clearRenzheng(scope.row)">
						清除实名
					</div>
		        </template>
		    </el-table-column>
		</el-table>
		<div class="page">
		    <el-pagination
		            background
		            @size-change="pageChange"
		            @current-change="handleCurrentChange"
		            :current-page="page"
		            :page-size="pageSize"
		            layout="total, sizes, prev, pager, next, jumper"
		            :total="page_totle">
		    </el-pagination>
		</div>
		
		
		<el-dialog
		        title="编辑"
				:close-on-click-modal="false"
				:modal-append-to-body="false"
				:append-to-body="true"
		        :visible.sync="isShow"
		        width="800px"
		>
		  <el-form ref="form" label-width="100px">
			 <el-form-item label="真实姓名">
				<el-input disabled size="small" v-model="form.name"
				></el-input>
			 </el-form-item>
			 <el-form-item label="注册手机号">
					<el-input size="small" v-model="form.phone"
					></el-input>
			  </el-form-item>
			  <el-form-item >
				  <el-button type="primary" @click="confirm" size="small">确定</el-button>
			  </el-form-item>
		  </el-form>
		</el-dialog>
	</div>
</template>

<script>
import selectUser from '@/components/selectUser.vue';
	export default {
		data(){
			return {
				page:1,
				pageSize:20,
				mid:'',
				renzheng_status:'-1',
				isShow:false,
				form:{
					phone:"",
					name:'',
					id:''
				}
			}
		},
		components:{
			selectUser
		},
		mounted() {
			this.lodeList()
		},
		methods:{
			clearRenzheng(row){
				if(confirm('是否清除实名')){
				
					this.$post('/user/clearShiMing',{id:row.id},res=>{
						this.$message.success('操作成功')
						this.lodeList()
					})
				}
				
			},
			confirm(){
				
				this.$post('/user/updUserPhone',this.form,res=>{
						this.$message.success('操作成功')
						this.lodeList()
						this.isShow = false
				})
			},
			editRow(row){
				this.isShow = true
				this.form.name = row.name
				this.form.phone = row.phone
				this.form.id = row.id
			},
			clearSearch(){
				this.mid = ''
				this.renzheng_status = '-1'
				this.page = 1
				this.$refs['selectUser'].mid = ''
				this.$refs['selectUser'].keywords = ''
				this.lodeList()
			},
			getUserId(val){
				this.page = 1
				this.mid = val
			},
			lodeList(){
				let params = {
					page:this.page,
					pageSize:this.pageSize,
					mid:this.mid,
					renzheng_status:this.renzheng_status
				}
				this.$post('/user/getUserList',params,res=>{
					let data = res.data.data
					this.page_totle = data.count
					this.list = data.result
				})
			},
		}
	}
</script>

<style>
</style>